home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / DELPHI.SWG / 0011_Playing WAV Files.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  740 b   |  27 lines

  1. {
  2. You can very simply play WAV files using the sndPlaySound
  3. function in the MMSYSTEM.DLL library. The tricky bit is in
  4. passing the filename to the function, which requires a
  5. null-terminated string. The little routine below converts
  6. the filename to an array of characters, which sndPlaySound
  7. is happy with.
  8.  
  9. Freeware, have fun!
  10. }
  11.  
  12. Add 'MMSystem' to Uses.
  13.  
  14. Add 'procedure PlaySound(WavFileName: String);' to declarations.
  15.  
  16. Add the code below to Implementation.
  17.  
  18. procedure MyForm.PlaySound(WavFileName: String);
  19. var
  20.    s: Array[0..79] of char;
  21. begin
  22. {Convert filename to a null-terminated string}
  23. StrPCopy(s, WavFileName);
  24. {Play the sound asynchronously}
  25. sndPlaySound(s, 0); {see mmsystem.hlp for other values}
  26. end;
  27.